package br.ufrr.patrimonio.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import br.ufrr.patrimonio.converter.BaseEntity;

@Entity
public class NotaFiscal implements Serializable, BaseEntity {
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="nf_id")
	private Long id;
	
	@Column(name="nf_numero", unique=true)
	private String numero;
	
	@Temporal(TemporalType.DATE)
	@Column(name="nf_data_emissao")
	private Calendar data = Calendar.getInstance();
	
	@Temporal(TemporalType.DATE)
	@Column(name="nf_recebido")
	private Calendar recebido  = Calendar.getInstance();
	
	@Temporal(TemporalType.DATE)
	@Column(name="nf_paga")
	private Calendar paga;
	
	@Column(name="nf_pagamento")
	private Boolean pagamento;
	
	@Column(name="nf_valor_total")
	private Double valor_total;
	
	@ManyToOne
	@JoinColumn(name="fk_empenho")
	private Empenho empenho;
	
	@ManyToOne
	@JoinColumn(name="fk_fornecedor")
	private Fornecedor fornecedor;
	
	@Column(name="nf_status")
	private String status;
	
	@Column(name="nf_obs")
	private String obs;
		
	@OneToMany
	(cascade=CascadeType.PERSIST, mappedBy="nota")
	private List<Item> itens = new ArrayList<Item>();
	
		
	/** Getters And Setters **/
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNumero() {
		return numero;
	}

	public void setNumero(String numero) {
		this.numero = numero;
	}

	public Calendar getData() {
		return data;
	}

	public void setData(Calendar data) {
		this.data = data;
	}

	public Double getValor_total() {
		return valor_total;
	}

	public void setValor_total(Double valor_total) {
		this.valor_total = valor_total;
	}

	public Calendar getRecebido() {
		return recebido;
	}

	public void setRecebido(Calendar recebido) {
		this.recebido = recebido;
	}

	public Calendar getPaga() {
		return paga;
	}

	public void setPaga(Calendar paga) {
		this.paga = paga;
	}

	public Empenho getEmpenho() {
		return empenho;
	}

	public void setEmpenho(Empenho empenho) {
		this.empenho = empenho;
	}

	public Fornecedor getFornecedor() {
		return fornecedor;
	}

	public void setFornecedor(Fornecedor fornecedor) {
		this.fornecedor = fornecedor;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getObs() {
		return obs;
	}

	public void setObs(String obs) {
		this.obs = obs;
	}

	public List<Item> getItens() {
		return itens;
	}

	public void setItens(List<Item> itens) {
		this.itens = itens;
	}

	public Boolean getPagamento() {
		return pagamento;
	}

	public void setPagamento(Boolean pagamento) {
		this.pagamento = pagamento;
	}
				
}
